package com.ihg.hiex.admin.entity.search;

import java.util.Map;

import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

/**
 * @author ZEAL
 *
 */
public class DelegateSearch implements QueryBuilder{

    private QueryOrder queryOrder;

    private QueryFilter queryFilter;

    private String name;

    private String emailAddress;

    private String telephone;

    private String hotelName;

    private String subRegion;

    private String jobTitle;

    private String reportTo;

    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {
        if (queryFilter == null || refresh) {
            queryFilter = new QueryFilter();

            queryFilter.addLike("name", name);
            queryFilter.addLike("emailAddress", emailAddress);
            queryFilter.addLike("telephone", telephone);
            queryFilter.addLike("hotelName", hotelName);
            queryFilter.addLike("subRegion", subRegion);
            queryFilter.addLike("jobTitle", jobTitle);
            queryFilter.addLike("reportTo", reportTo);
        }
        return queryFilter;
    }

    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#getOrder()
     */
    public QueryOrder getOrder() {
        queryOrder = new QueryOrder("lastModifyTime", "DESC");

        return queryOrder;
    }

    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {
        return "FROM Delegate WHERE disabled = false " + getPreparedFilter(false).clauseSentence();
    }

    /* (non-Javadoc)
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {
        return getPreparedFilter(false).parameters();
    }

    /**
     * @return the queryOrder
     */
    public QueryOrder getQueryOrder() {
        return queryOrder;
    }

    /**
     * @return the queryFilter
     */
    public QueryFilter getQueryFilter() {
        return queryFilter;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the emailAddress
     */
    public String getEmailAddress() {
        return emailAddress;
    }

    /**
     * @return the telephone
     */
    public String getTelephone() {
        return telephone;
    }

    /**
     * @return the hotelName
     */
    public String getHotelName() {
        return hotelName;
    }

    /**
     * @return the subRegion
     */
    public String getSubRegion() {
        return subRegion;
    }

    /**
     * @return the jobTitle
     */
    public String getJobTitle() {
        return jobTitle;
    }

    /**
     * @return the reportTo
     */
    public String getReportTo() {
        return reportTo;
    }

    /**
     * @param queryOrder the queryOrder to set
     */
    public void setQueryOrder(QueryOrder queryOrder) {
        this.queryOrder = queryOrder;
    }

    /**
     * @param queryFilter the queryFilter to set
     */
    public void setQueryFilter(QueryFilter queryFilter) {
        this.queryFilter = queryFilter;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param emailAddress the emailAddress to set
     */
    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    /**
     * @param telephone the telephone to set
     */
    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    /**
     * @param hotelName the hotelName to set
     */
    public void setHotelName(String hotelName) {
        this.hotelName = hotelName;
    }

    /**
     * @param subRegion the subRegion to set
     */
    public void setSubRegion(String subRegion) {
        this.subRegion = subRegion;
    }

    /**
     * @param jobTitle the jobTitle to set
     */
    public void setJobTitle(String jobTitle) {
        this.jobTitle = jobTitle;
    }

    /**
     * @param reportTo the reportTo to set
     */
    public void setReportTo(String reportTo) {
        this.reportTo = reportTo;
    }
}
